﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKStairs.Manage;
using HYView;

namespace YJKStairs
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdCreateStairsClearHeightDimension : IExternalCommand
	{
		Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			if (Convert.ToInt32(commandData.Application.Application.VersionNumber) < 2014)
			{
				message = "此功能只在Revit2014及其以上版本可用。";
				return Autodesk.Revit.UI.Result.Failed;
			}
			CmdViewType types = CmdViewType.Section;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			DialogResult dialogResult = MessageBox.Show("特别提示： 软件暂时不支持以草图方式绘制的楼梯!!!\r\n是： 继续使用 ， 否： 退出", "盈建科提示", MessageBoxButtons.YesNo);
			if (DialogResult.Yes != dialogResult)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			if (!StairsClearHeightDimensionCreator.CreateClearHeightDimension(commandData))
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
